#include "SoundManager.h"
#include "SoundManager.impl.cc"

namespace noria { namespace media { namespace sound {

	class SoundManager final : public ISoundManager
	{
	public:
		virtual void PlayMusic(const char* file) override
		{
			m_impl.PlayMusic(file);
		}
		virtual void Stop() override
		{
			m_impl.Stop();
		}
	public:
		virtual void Dispose() override
		{
			delete this;
		}
		virtual const IType* const GetType() const override
		{
			return GetSoundManagerType();
		}
		virtual IReflectable* Invoke(const char* name, IReflectable** args) override
		{
			// PlayMusic
			if (strcmp(name, "PlayMusic") == 0)
			{
				const char* file;
				AcMarshal.Unbox(*args[0], file);

				this->PlayMusic(file);
			}

			return nullptr;
		}
	private:
		SoundManagerImpl m_impl;
	private:
		friend const IType* const GetSoundManagerType();
		class Type final : public IType
		{
		public:
			virtual void Dispose() override
			{
			}
			virtual IReflectable* CreateInstance() const override
			{
				return new SoundManager();
			}
			virtual const char* const GetName() const override
			{
				return "SoundManager";
			}
			virtual const char* const GetFullName() const override
			{
				return "noria.media.sound.SoundManager";
			}
		};
	};

	const IType* const GetSoundManagerType()
	{
		static SoundManager::Type type;
		return &type;
	}

}}}